<?php
/**
 * Introduction: 微店月销售额记录表  micro_shop_sales_flow
 */

namespace Common\Model;


use Think\Model;

class MicroShopSalesFlowModel extends Model
{
    //定义数据库连接信息
    protected $connection;

    //定义表名
    protected $tableName = 'micro_shop_sales_flow';

    /**
     * 初始化
     */
    public function _initialize()
    {

        $this->connection = C('Databaese');

    }


    /**
     * 获取某店铺的团队销售金额
     * @param int $shopId
     * @param int $dateStart 示例 201601：null - 不限制起始时间
     * @param int $dateEnd 示例 201601: null
     */
    public function getGroupAmount($shopId)
    {
        $amount = $this->where("member_id=$shopId")->field("sum(group_sales) as price")->find();

        return $amount['price']?$amount['price']:0;
    }

    /**
     * 获取某店铺的销售金额
     * @param int｜array $shopsId
     * @param int $dateStart 示例 201601：null - 不限制起始时间
     * @param int $dateEnd 示例 201601: null
     */
    public function getSelfAmount($shopsId)
    {
        $amount = $this->where("member_id=$shopsId")->field("sum(self_sales) as price")->find();

        return $amount['price']?$amount['price']:0;
    }

}